package com.zhangtai.modules.controller.admin;



import java.util.*;


import com.zhangtai.modules.dao.ContractSubGroupDao;
import com.zhangtai.modules.dto.AwardInfoAndApplicantDto;
import com.zhangtai.modules.entity.system.ContractGroupEntity;
import com.zhangtai.modules.entity.system.ContractSubGroupEntity;
import com.zhangtai.modules.service.system.ContractGroupService;
import com.zhangtai.modules.service.system.ContractSubGroupService;
import com.zhangtai.modules.vo.ContractMainSubVO;
import com.zhangtai.utils.PageResult;
import com.zhangtai.utils.PageUtils;
import com.zhangtai.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;



/**
 * 合同主体组表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-11-26 18:04:19
 */
@Api(tags="合同主体组表接口")
@RestController
@RequestMapping("contractGroup")
@Slf4j
public class ContractGroupController {
    @Autowired
    private ContractGroupService contractGroupService;

    @Autowired
    private ContractSubGroupService contractSubGroupService;

    @Autowired
    private ContractSubGroupDao contractSubGroupDao;
    /**
     * 列表
     */
    @GetMapping("/queryContractSubGroupPage")
    @ApiOperation(value = "根据主表id查询合同子表主体组表信息")
    public R list(@RequestParam("id")String id){

        List<ContractSubGroupEntity> subContractList = contractSubGroupDao.getSubContractList(new Long(id));

        return R.ok(subContractList);
    }

    /**
     * 列表
     */
    @GetMapping("/queryContractGroupPage")
    @ApiOperation(value = "分页查询合同主表主体组表信息")
    public R listMain(
                  @RequestParam(value = "groupName", required = false) String groupName,
                  @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                  @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){

        PageResult result = contractGroupService.queryPage(groupName, pageNum, pageSize);

        return R.ok(result);
    }

    /**
     * 信息
     */
    @GetMapping("/getContractGroup")
    @ApiOperation("根据id查询合同主体组表信息")
    public R info(@RequestParam("id") String id){
        ContractGroupEntity contractGroup = contractGroupService.getByIdE(new Long(id));

        return R.ok(contractGroup);
    }

    /**
     * 保存
     */
    @PostMapping("/saveContractGroup")
    @ApiOperation("保存合同主体组表信息")
    public R save(@RequestBody(required = false) ContractMainSubVO contractMainSubVO){
        contractGroupService.save(contractMainSubVO);
        return R.ok();
    }

    /**
     * 删除id
     */
    @DeleteMapping("/deleteContractGroup")
    @ApiOperation("删除合同主体组信息")
    public R delete(@RequestParam("id") String id){
        contractGroupService.removeOneById(new Long(id));
        return R.ok();
    }

//    /**
//     * 删除
//     */
//    @DeleteMapping("/delete")
//    @ApiOperation("删除合同主体组表信息")
//    public R delete(@RequestBody Long[] ids){
//        contractGroupService.removeByIdsE(Arrays.asList(ids));
//
//        return R.ok();
//    }

}
